﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace UI
{
    public partial class InsertCar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.DataSource = new CarTypeBLL().Dat();
                DropDownList1.DataTextField = "TypeName";
                DropDownList1.DataValueField = "TypeID";
                DropDownList1.DataBind();
            }
            

        }


        protected void Button1_Click1(object sender, EventArgs e)
        {

                CarInfoModels c = new CarInfoModels()
                {
                    CarName = this.TextBox1.Text,
                    CarPrice = int.Parse(this.TextBox2.Text),
                    Place = this.TextBox3.Text,
                    Desc = this.TextBox4.Text,
                    TypeID = Convert.ToInt32(this.DropDownList1.Text)
                };
                if (new CarInfoBLL().Insert(c))
                {
                    Response.Redirect("CarInfoUI.aspx");
                }
                else
                {
                    Response.Write("添加失败！");
                }

            }


    }
}